package com.zs.netlibrary.http.result;

import android.content.Context;
import android.text.TextUtils;
import android.util.Log;

import com.zs.netlibrary.http.result.IResultCallback;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 *
 * Created by sheng on 2017/8/17.
 */

public abstract class ResultCallback implements IResultCallback{
    private Context context;
    public ResultCallback (){
        this.onNetStart();
    }

    public ResultCallback(Context context){
        this.context = context.getApplicationContext();
        this.onNetStart();
    }

    @Override
    public void onNetStart() {
        // TODO:开始访问网络的处理

    }

    @Override
    public void onNetComplete() {
        // TODO:访问网络完毕，可以做些处理 比如：隐藏获取数据的进度条等
    }

    @Override
    public void onFailed() {

    }

    @Override
    public void onResponse(String data) {

    }

    protected void showLoginActivity(){
        try {
            Class aClass = Class.forName("com.zs.tools.utils.IntentUtils");
            Method method = aClass.getMethod("logout");
            method.invoke(null);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }

    protected void onNoMsg(){

    }

    protected void onWrongMsg(String msg){

    }
    protected void onMsg(int error, String msg){

    }

    protected void onDataFine(JSONObject jsonObject){

    }

    protected void onDataFine(Object cls){

    }

    protected void onDataFine(JSONArray jsonArray){

    }

    public void onDataFine(String data){

    }
    public void onDataFine(int data){

    }

    public void onErrorMsg(int error, String msg){

    }

    @Override
    public void onResponse(InputStream inputStream) {

    }
}
